package com.guigu.ssm.controller;

import com.guigu.ssm.pojo.Login;
import com.guigu.ssm.serivce.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/acc")
public class AccController {
    @Autowired(required = false)
    LoginService loginService;

    @RequestMapping("/login")
    @ResponseBody
    public Boolean userLogin(@RequestBody Login login,HttpServletRequest request){
        Login denglu = loginService.denglu(login);
        if (denglu != null) {
            request.getSession().setAttribute("users",denglu);
            return true;
        }else {
            return false;
        }
    }
}
